<?php

namespace App\Admin\Actions\Order;

use App\Models\yb\ExchangeGoodsOrderModel;
use Encore\Admin\Actions\RowAction;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;


class ExchangeDeliverGoods extends RowAction
{
    public $name = '发货';

    /**
     * @param Model $model
     * @return string
     */
    public function handle(Model $model, Request $request)
    {
        $express_name = $request->get('express_name');

        $courier_number = $request->get('courier_number');

        ExchangeGoodsOrderModel::where(['id'=>$model->id])->update([
            'status' => 1,
            'courier_number' => $courier_number,
            'express_name' =>$express_name,
            'delivery_date' => date('Y-m-d H:i:s',time())
        ]);

        return $this->response()->success('操作成功')->refresh();

    }

    /**
     * @param $star
     * @return string
     */
    public function display($id)
    {
        return  '<button type="button" class="btn btn-xs btn-info btn-flat">发货</button>';
    }


    public function form()
    {
        $this->text('express_name','快递名称');
        
        $this->text('courier_number','快递单号');

    }

}